<div ui-view>
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li>
                <a href="javascript:;">WMS</a>
                <i class="fa fa-circle"></i>
            </li>
            <li>
                <a href="javascript:;">Task</a>
                <i class="fa fa-circle"></i>
            </li>
            <li>
                <a href="#">Generic Task</a>
            </li>
        </ul>
    </div>
    <div class="portlet light bordered order-list-container" style="margin: 15px;">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject bold">General Task List</span>
            </div>
            <div class="actions">
                <a ng-click="openCreateTaskDialog()" permission-check="{{'task::generalTask_write'}}">
                    <b>Create Task</b>
                </a>
            </div>
        </div>
        <div class="portlet-body form form-horizontal">
            <form>
                <div class="row form-group">
                    <div class="col-md-3">
                        <label>Task ID</label>
                        <lt-tags-input ng-model="search.taskIds" placeholder="Enter Task ID" fill="TASK-" ng-keyup="keyUpSearch($event)"></lt-tags-input>
                    </div>
                    <div class="col-md-3">
                        <label>Assignee</label>
                        <user-auto-complete name="assignee" allow-clear="true"
                                            ng-model="search.assigneeUserId"></user-auto-complete>
                    </div>
                    <div class="col-md-3">
                        <label>Status</label>
                        <task-status-auto-complete  allow-clear="true"  ng-model="search.status"></task-status-auto-complete>
                    </div>
                </div>
                <div class="row form-group">
                    <div class="col-md-3">
                        <label>Start Time From</label>
                        <lt-date-time placeholder="From" date-format="yyyy-mm-dd hh:ii" minute-step="60"
                                      value="search.startTimeFrom"></lt-date-time>
                    </div>
                    <div class="col-md-3">
                        <label>Start Time To</label>
                        <lt-date-time placeholder="To" date-format="yyyy-mm-dd hh:ii" minute-step="60"
                                      value="search.startTimeTo"></lt-date-time>
                    </div>
                    <div class="col-md-3">
                        <label>End Time From</label>
                        <lt-date-time placeholder="From" date-format="yyyy-mm-dd hh:ii" minute-step="60"
                                      value="search.endTimeFrom"></lt-date-time>
                    </div>
                    <div class="col-md-3">
                        <label>End Time To</label>
                        <lt-date-time placeholder="To" date-format="yyyy-mm-dd hh:ii" minute-step="60"
                                      value="search.endTimeTo"></lt-date-time>
                    </div>
                </div>
                <div class="form-actions right" >
                    <waitting-btn type="button" btn-class="btn blue" ng-click="searchTasks()"
                                  value="'Search'" is-loading="loading"></waitting-btn>
                </div>

            </form>
            <div class="table-scrollable item-list-continer">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th class="col-md-1">Task ID</th>
                        <th class="col-md-1">Assignee</th>
                        <th class="col-md-1">Status</th>
                        <th class="col-md-1">Priority</th>
                        <th class="col-md-2">Start Time</th>
                        <th class="col-md-2">End Time</th>
                        <th class="col-md-3">Description</th>
                        <th class="col-md-1" permission-check="{{'task::generalTask_write'}}">Actions</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="task in tasks track by $index">
                        <td>{{ task.id }}</td>
                        <td>{{ task.assignee.firstName + ' ' + task.assignee.lastName}}</td>
                        <td>{{ task.status }}</td>
                        <td>{{ task.priority }}</td>
                        <td>{{ task.startTime | amDateFormat:'YYYY-MM-DD HH:mm'}}</td>
                        <td>{{ task.endTime | amDateFormat:'YYYY-MM-DD HH:mm' }}</td>
                        <td>{{ task.description }}</td>
                        <td permission-check="{{'task::generalTask_write'}}">
                            <a ng-click="openCreateTaskDialog(task.id)"> Edit </a>
                            <span> | </span>
                            <a ng-click="deleteTask(task.id)"  ng-show="task.status == 'New'"> Delete </a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <pager total-count="paging.totalCount" current-page ="paging.pageNo" page-size="pageObj.pageSize" load-content="loadContent(currentPage)"></pager>
        </div>
    </div>
</div>